package com.huluobo.a2202mvvm_im_douyindemo.addFriend;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;

import android.os.Bundle;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.huluobo.a2202mvvm_im_douyindemo.R;
import com.huluobo.a2202mvvm_im_douyindemo.databinding.ActivityAddFriendBinding;
import com.huluobo.a2202mvvm_im_douyindemo.mvvmBase.BaseMVVMActivity;

public class AddFriendActivity extends BaseMVVMActivity<ActivityAddFriendBinding, AddFriendViewModel> {

    @Override
    protected void initData() {
        viewModel.addFriendSuccess.observe(this, ToastUtils::showLong);

        viewModel.addFriendFailed.observe(this, ToastUtils::showLong);
    }

    @Override
    protected void intiView() {
        dataBinding.addFriendBtn.setOnClickListener(v -> {
            viewModel.addFriend(
                    dataBinding.addFriendUsername.getText().toString(),
                    dataBinding.addFriendReason.getText().toString()
            );
        });
    }

    @Override
    protected Class<AddFriendViewModel> getViewModel() {
        return AddFriendViewModel.class;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_add_friend;
    }
}